<div id="error"></div>
<script language="javascript">
    // apply filters
    var applyFilter = function(){
        jQuery("#list").setGridParam({
            url: '<?php echo site_url() ?>/trancrearcompania/datahistorico',
            page:1,
            postData:{
                search: true,
                name: $('#name').val(),
                dispara_fin:$('.f_fin:checked').val()
            }
        }).trigger("reloadGrid");
    }

    jQuery(document).ready(function(){
        jQuery("#list").jqGrid({
            url: '<?php echo site_url() ?>/trancrearcompania/datahistorico2/h',
            mtype: 'POST',
            datatype: 'json',
            colNames:['ID','Referencia', 'Tipo','jurisdic.','Registro','Etapa A.','Estatus',
            'User','Responsable'],
            colModel :[
                {name:'IdCompania', index:'IdCompania', width:5,hidden:true},
                {name:'NombreCompania', index:'NombreCompania', width:20},
                {name:'IdServicio', index:'IdServicio', width:10},
                {name:'IdJurisdiccion', index:'IdJurisdiccion', width:8},
            	{name:'FechaUsrCompania', index:'FechaUsrCompania', width:11},
            	{name:'IdEtapa',index:'IdEtapa',width:8},
            	{name:'IdEstatus',index:'IdEstatus',width:7},
            	
            	{name:'User', index:'User', width:7},
            	{name:'Responsable', index:'Responsable', width:7}	
                ],
            pager: jQuery('#pager'),
            hiddengrid: true,
            sortname: 'IdCompania',
            rowNum:150,
            rowList:[150,200],
            sortorder: "asc",
            height: '100%',
            width: '550',
            imgpath: _base_url + 'public/css/jqgrid/flex/images',
            viewrecords: true,
            multiselect: false,
            onSelectRow: function(ids) 
            {
            	if(ids != null) 
            	{
            		var rec = jQuery("#list").getRowData(ids);
            		lol=ids;
            		
            		jQuery("#list_etapas").setGridParam({url : _site_url + '/trancrearcompania/procesos_data', page : 1, mtype:'POST',postData:{id_compania:rec.IdCompania}}).setCaption("Etapas: " + rec.IdCompania).trigger('reloadGrid');
            	
            	}
            },
            adjacents: 4,
            jsonReader: { repeatitems : false, IdCompania: "0" }
        }).navGrid('#pager',{add:false,del:false,edit:false,search:false,position:"left"}).navButtonAdd('#pager',{caption:"", buttonimg: _base_url + "public/css/jqgrid/flex/images/text_columns.png", onClickButton:function(){ jQuery("#list").setColumns();} })


     
       
        $('#apply_filter').bind('click', applyFilter);
    });

 function getCheckedValue(radioObj) 
 {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
   
    
 function cargarporfecha()
 {
 	if ($('#fechasysoruser').val())
 	{
 		a=getCheckedValue($('#fechasysoruser'));
 		if (a=='')
 		{
 			valor='sys';
 		}
 		else
 		{
 			valor=a;
 		}
 		
 		if(valor=='user')
 		{
 		jQuery("#list").setGridParam({url : _site_url + '/trancrearcompania/data', page : 1}).trigger('reloadGrid');
 		jQuery("#list_etapas").setGridParam({url : _site_url + '/trancrearcompania/procesos_data', page : 1}).trigger('reloadGrid');
 		}
 		if(valor=='sys')
 		{
 			jQuery("#list").setGridParam({url : _site_url + '/trancrearcompania/data2', page : 1}).trigger('reloadGrid');
 			jQuery("#list_etapas").setGridParam({url : _site_url + '/trancrearcompania/procesos_data2', page : 1}).trigger('reloadGrid');
 		}
 	}
 }
</script>
<div class="table_container">
<div align="center" style="width:auto;">

</div>
<table>
<tr>
	<td><?php $this->load->view('estatus_filters'); ?></td>
</tr>
<tr><td><br /><div id="titulo">Historico Seguimiento de Servicios<hr /></div><br /></td></tr>
<tr>
<td>
    <table id="list" class="scroll"></table>
    <div id="pager" class="scroll" style="text-align:center;"></div>
</td>
 </tr>
<?php $this->load->view('etapas_trx_list2'); ?>
</table>
</div>